package com.ttwm.controller;

import com.ttwm.pojo.Swiper;
import com.ttwm.service.SwiperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class SwiperController {
    @Autowired
    private SwiperService swiperService;

    @PostMapping(value = {"/ttwm/swiperAll"})
    public Map<String ,Object> swiperAll(){
        Map map = new HashMap<String ,Object>();
        List<Swiper> swiperList = swiperService.swiperAll();
        if (swiperList.isEmpty()){
            map.put("success",false);
            map.put("msg","失败");
        }else {
            map.put("success",true);
            map.put("msg","成功");
            map.put("list",swiperList);
        }
        return map;
    }
}
